<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	// http://localhost:8080/staffmgr/
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ request.getContextPath() + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>部门信息</title>
</head>
<base href="<%=basePath%>">
<body>

<!-- 引入haeder.jsp -->
<!--  静态引入-->
<%@ include file="../header.jsp" %>
<!-- 动态引入 -->
<%-- <jsp:include page="../header.jsp"></jsp:include> --%>

	<a href="dept/add.jsp">添加</a>

	<table border="1" width="100%" cellspacing="0">
		<caption>部门列表</caption>
		<tr>
			<th>ID</th>
			<th>部门名</th>
			<th>办公室</th>
			<th>电话</th>
			<th>邮箱</th>
			<th>操作</th>
		</tr>
		<c:if test="${depts==null }">
			<!-- 跳转页面 -->
			<jsp:forward page="../dept.do?action=list"></jsp:forward>
		</c:if>
		<c:forEach items="${depts }" var="dept">
			<tr>
				<td>${dept.id }</td>
				<td>${dept.name }</td>
				<td>${dept.room }</td>
				<td>${dept.phone }</td>
				<td>${dept.email }</td>
				<td>
				<a href="dept.do?action=remove&id=${dept.id }">删除</a>
				<a href="dept/edit.jsp?id=${dept.id }">编辑</a>
				</td>
			</tr>

		</c:forEach>
	</table>
	<!-- 当删除错误 返回页面，数据库修改了id 但是页面没更新 发生删除错误。 -->
	<script type="text/javascript">
	    <c:if test="${param.error!=null}">
	  alert('${param.error}');
	 </c:if>
	</script>
</body>
</html>